package com.aponteitor.desktop;

import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.SplashScreen;

/**
 * @author penetrol@gmail.com
 */
public class SplashUtil {

	private static final SplashScreen splash = SplashScreen.getSplashScreen();
	private static Graphics2D graphics2d;
	
	public static void changeStatusSplash(String text) {
	    if (splash == null){
	        return;
	    }
		if (graphics2d == null) {
			graphics2d = splash.createGraphics();
		}
		graphics2d.setComposite(AlphaComposite.Clear);
		graphics2d.fillRect(0, 0, 400, 338);
		graphics2d.setPaintMode();
		graphics2d.setColor(Color.BLACK);
		graphics2d.drawLine(10, 315, 390, 315);
		graphics2d.drawString(text, 120, 330);
		splash.update();
	}

	public static void close() throws IllegalStateException {
		if(splash != null && splash.isVisible()){
			splash.close();
			graphics2d = null;
		}
	}
}
